package com.mark.service.impl;

import com.mark.entity.school.UPatriarch;
import com.mark.mapper.UPatriarchMapper;
import com.mark.service.UPatriarchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * (UPatriarch)表服务实现类
 *
 * @author Deng PengFei
 * @since 2021-10-27 11:17:18
 */
@Service
public class UPatriarchServiceImpl implements UPatriarchService {
    @Autowired
    private UPatriarchMapper uPatriarchMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param patId 主键
     * @return 实例对象
     */
    @Override
    public UPatriarch queryById(Object patId) {
        return this.uPatriarchMapper.queryById(patId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<UPatriarch> queryAllByLimit(int offset, int limit) {
        return this.uPatriarchMapper.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param uPatriarch 实例对象
     * @return 实例对象
     */
    @Override
    public UPatriarch insert(UPatriarch uPatriarch) {
        this.uPatriarchMapper.insert(uPatriarch);
        return uPatriarch;
    }

    /**
     * 修改数据
     *
     * @param uPatriarch 实例对象
     * @return 实例对象
     */
    @Override
    public UPatriarch update(UPatriarch uPatriarch) {
        this.uPatriarchMapper.update(uPatriarch);
        return this.queryById(uPatriarch.getPatId());
    }

    /**
     * 通过主键删除数据
     *
     * @param patId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Object patId) {
        return this.uPatriarchMapper.deleteById(patId) > 0;
    }
}